import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Demo9 {
package student.day20;

    public class student {
        private int no;
        private String name;
        private int age;
        private double height;
        private String sex;
        public student(){

        }
        public student (int no,String name,int age,double height,String sex){
            this.no=no;
            this.name=name;
            this.age=age;
            this.height=height;
            this.sex=sex;
        }

        public int getNo() {
            return no;
        }

        public void setNo(int no) {
            this.no = no;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public double getHeight() {
            return height;
        }

        public void setHeight(double height) {
            this.height = height;
        }

        public String getSex() {
            return sex;
        }

        public void setSex(String sex) {
            this.sex = sex;
        }

        public String format(){
            return no+","+name+","+age+","+height+","+sex+"\n";
        }


    }
package student.day20;

import student.day10.Student;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

    public class studentSystem {
        static Map<String , student> studentMap = new HashMap<>();

        static {
            //从文件里读取学生数据存入到map集合
            studentMap.put("zs",new student(1,"zs",18,180,"男"));
            studentMap.put("ls",new student(2,"ls",18,180,"女"));
        }
        static Scanner input = new Scanner(System.in);

        public static void main(String[] args) {
            while (true){
                //菜单
                System.out.println("1.查看所有学生的信息");
                System.out.println("2.输入姓名搜索学生信息");
                System.out.println("3.增加学生信息");
                System.out.println("4.修改学生信息");
                System.out.println("5.删除学生信息");
                System.out.println("6.退出");
                System.out.println("请输入编号选择功能");

                //接收控制台输入的信息
                int index = input.nextInt();

                //根据输入的数字来调用相应的功能
                if(index == 1){
                    selectAll();
                }else if(index == 2){
                    selectByName();
                }else if(index == 3){
                    add();
                }else if(index == 4){
                    pudate();
                }else if(index == 5){
                    delete();
                }else if(index == 6){
                    break;
                }else {
                    System.out.println("没有这个选项");
                }

            }
        }
        //菜单1 的方法实现
        public static void selectAll(){
            if(studentMap.size() == 0){
                System.out.println("没有学生信息");
            }else {
                //输出所有的值
                Collection<student> values = studentMap.values();
                for (student value : values) {
                    System.out.println(value);
                }
            }
        }

        //菜单2 的方法实现
        public static void selectByName(){
            System.out.println("请输入要查询的学生姓名");
            String name = input.next();
            student student =studentMap.get(name);
            if (student == null){
                System.out.println("没有此学生");
            }else {
                System.out.println(student);
            }
        }

        //菜单3 的方法实现
        public static void add(){
            //1.创建学生对象，但是此时学生对象的属性都是默认值
            student student = new student();
            //2.通过录入器给学生的属性录入值
            System.out.println("请输入学生的编号");
            student.setNo(input.nextInt());
            System.out.println("请输入姓名");
            student.setName(input.next());
            System.out.println("请输入年龄");
            student.setAge(input.nextInt());
            System.out.println("请输入身高");
            student.setHeight(input.nextDouble());
            System.out.println("请输入性别");
            student.setSex(input.next());
            studentMap.put(student.getName() , student);

        }

        //菜单4 方法实现
        public static void pudate(){
            student student = new student();
            System.out.println("请输入你要修改的学生姓名");
            student.setName(input.next());
            if (studentMap.get(student.getName()) != null){
                System.out.println("请输入学生的编号");
                student.setNo(input.nextInt());
                System.out.println("请输入姓名");
                student.setName(input.next());
                System.out.println("请输入年龄");
                student.setAge(input.nextInt());
                System.out.println("请输入身高");
                student.setHeight(input.nextDouble());
                System.out.println("请输入性别");
                student.setSex(input.next());
                studentMap.put(student.getName() , student);
            }else {
                System.out.println("没有这个学生信息");
            }
        }

        //菜单5 的方法实现
        public static void delete (){
            String str = input.next();
            if(studentMap.remove(str) != null){
                System.out.println("删除成功");
            }else {
                System.out.println("没有这条学生信息");
            }
        }



    }


package student.day21;

import student.day16.ArrayListDemo;

import javax.xml.transform.Source;
import java.util.ArrayList;

    public class Demo1 {
        public static void main(String[] args) {
//
//        String s1 ="sbc";
//        String s2= new String("sbc");
//        System.out.println(s1.equals(s2));


            //没有泛型的集合
            ArrayList list = new ArrayList();
            list.add("java");
            list.add(100);
            list.add(true);

            //遍历集合
            for (int i = 0; i < list.size(); i++) {
                Object o = list.get(i);
                System.out.println(o);
            }
            //有泛型的集合
            ArrayList<String> strlist = new ArrayList<>();
            strlist.add("sajkfha");
            strlist.add("safhueauifg");
//            strlist.add(100)  //报错，因为不是string类型
            //遍历集合
            for (String s : strlist) {
                System.out.println(s);
            }
        }
    }
package student.day22;


    //泛型类的定义 T创建对象的时候里指定具体的数据类型
    public class Demo1<T> {
        private T key;
        public Demo1(T key) {
            this.key = key;
        }
        public T getKey(){
            return key;
        }
        public void setKey(T key){

        }

        @Override
        public String toString() {
            return "Demo1{" +
                    "key=" + key +
                    '}';
        }
    }

}
